//非区域权限
export function getPermission(perVal) {
    let pers = [];
    let roleValue = window.localStorage.getItem('role');
    if (roleValue) {
        if (roleValue.includes(',')) {
            for (let newRoleValue of roleValue.split(',')) {
                pers = Array.from(new Set([...getPermissionByRoleValue(newRoleValue), pers]))
            }
        } else {
            pers = getPermissionByRoleValue(roleValue)
        }
    }
    let hasPer = pers.some(item => {
        return item == perVal
    });
    return hasPer;
}

function getPermissionByRoleValue(roleValue) {
    let pers = [];
    //首页
    if (roleValue === 'cropAdmin') {
        pers = ['centerBottomZbLeft', 'centerLeft1Bottom', 'centerBottom',
            'displayOfSpecialProjectTableEdit', 'displayOfSpecialProjectTableDel',
            'priceLibraryImport', 'priceLibraryDownLoad', 'priceLibraryEdit', 'priceLibraryOutport'
            , 'problemSearchEdit',
            'fileQueryAdd', 'fileQueryImport', 'fileQueryOutport', 'fileQueryDownload', 'fileQueryEdit', 'fileQueryDel']
    }
    if (roleValue === 'system') {
        pers = ['warningPrompt', 'centerLeft1Bottom', 'centerBottom', 'tagNameBtn',
        'displayOfSpecialProjectTableEdit', 'displayOfSpecialProjectTableDel',
        'priceLibraryImport', 'priceLibraryDownLoad', 'priceLibraryEdit', 'priceLibraryOutport'
        , 'problemSearchEdit',
        'fileQueryAdd', 'fileQueryImport', 'fileQueryOutport', 'fileQueryDownload', 'fileQueryEdit', 'fileQueryDel',
        'regulatoryLibraryAdd','regulatoryLibraryEdit','lawControl']
    }
    // 审计部门
    else if (roleValue === 'sjbm') {
        pers = ['warningPrompt', 'centerLeft1Bottom', 'centerBottom', 'tagNameBtn',
            'displayOfSpecialProjectTableEdit', 'displayOfSpecialProjectTableDel',
            'priceLibraryImport', 'priceLibraryDownLoad', 'priceLibraryEdit', 'priceLibraryOutport'
            , 'problemSearchEdit',
            'fileQueryAdd', 'fileQueryImport', 'fileQueryOutport', 'fileQueryDownload', 'fileQueryEdit', 'fileQueryDel',
            'regulatoryLibraryAdd','regulatoryLibraryEdit','lawControl']
    }
    //审计领导
    else if (roleValue === 'sjbm_ld') {
        pers = ['warningPrompt', 'centerLeft1Bottom', 'centerBottom', 'tagNameBtn',
            'displayOfSpecialProjectTableEdit', 'displayOfSpecialProjectTableDel',
            'priceLibraryImport', 'priceLibraryDownLoad', 'priceLibraryEdit', 'priceLibraryOutport'
            , 'problemSearchEdit',
            'fileQueryAdd', 'fileQueryImport', 'fileQueryOutport', 'fileQueryDownload', 'fileQueryEdit', 'fileQueryDel',
            'regulatoryLibraryAdd','regulatoryLibraryEdit','lawControl']
    }
    //局领导
    else if (roleValue === 'jld') {
        pers = ['warningPrompt', 'centerLeft1Bottom', 'centerBottom', 'tagNameBtn',
            'displayOfSpecialProjectTableEdit', 'displayOfSpecialProjectTableDel',
            'priceLibraryImport', 'priceLibraryDownLoad', 'priceLibraryEdit', 'priceLibraryOutport'
            , 'problemSearchEdit',
            'fileQueryAdd', 'fileQueryImport', 'fileQueryOutport', 'fileQueryDownload', 'fileQueryEdit', 'fileQueryDel']
    }
    //警保部门
    else if (roleValue === 'jbbm1') {
    
        pers = ['agencyMatters', 'warningPrompt', 'centerBottom', 'titleAddWord', 'centerLeft1Bottom','fileQueryOutport','priceLibraryOutport','fileQueryAdd', 
        'fileQueryImport','fileQueryEdit', 'fileQueryDel',"fileQueryDownload",'displayOfSpecialProjectTableEdit', 'displayOfSpecialProjectTableDel']
    }
    //业务领导 业务部门
    else if (roleValue === 'ywbm_ld' || roleValue === "xmdw_yw") {
        pers = ['agencyMatters', 'warningPrompt', 'centerBottom', 'titleAddWord', 'centerLeft1Bottom','fileQueryOutport','priceLibraryOutport']
    }
    return pers;
}

export default {
    getPermission
}

